local function getupvaluetable(func, inname)
	local i = 1
	while true do
		local name, value = debug.getupvalue(func, i)
		if name == nil then
			return
		end
        
        if name == inname then
            return i,value
        end
        
		i=i+1
	end
end

local function get_up(f)  
        local u = {}  
        if not f then  
                return u  
        end  
        local i = 1  
        while true do  
                local name, value = debug.getupvalue(f, i)  
                if name == nil then  
                        return u  
                end  
                u[name] = value  
                i = i + 1  
        end  
        return u  
end

if not _P then
	print "inject error!"
	return
end

local lua = _P.lua
local skynet = lua.skynet
-- print('ffffffff',tostring_r(skynet.call))
-- print('ffffffff',getupvaluetable(lua.MODULES.socket.open,'util'))
--print('ffffffff',tostring_r(get_up(lua.MODULES.socket.open)))
local _, create_game_session = getupvaluetable(lua.MODULES.socket.open,'create_game_session')
local _, client_sessions = getupvaluetable(lua.MODULES.socket.open,'client_sessions')
local _, game_session_fds = getupvaluetable(lua.MODULES.socket.open,'game_session_fds')
local _, util = getupvaluetable(lua.MODULES.socket.open,'util')
local _, gate = getupvaluetable(lua.MODULES.socket.open,'gate')
print('ffffffff',tostring_r(skynet.dispatch))
print('ffffffff',gate)
-- print('ffffffff',getupvaluetable(lua.MODULES.socket.open,'gate'))
-- print('ffffffff',getupvaluetable(lua.MODULES.socket.data,'gate'))
-- local gate = getupvaluetable(lua.MODULES.socket.open,'gate')
-- print('ffffffff',getupvaluetable(lua.MODULES.socket.open,'client_sessions'))
-- local _,handle_data = getupvaluetable(lua.MODULES.socket.data,'handle_data')
-- print('ffffffff',getupvaluetable(handle_data,'check_client_request'))
--print('ffffffff',getupvaluetable(lua.handle_data,'ACCOUNT_MSG_RANGE_MIN'))

-- lua.MODULES.socket.open = function(fd, addr)
-- 	local ipaddr = addr:sub(1,addr:find(':')-1)
-- 	skynet.error("New client from : " .. addr)
-- 	skynet.call(gate,'lua','accept',fd)

-- 	local game_session = create_game_session()
-- 	print('open new session',fd,game_session)
-- 	client_sessions[fd] = {
-- 		s = game_session,
-- 		p = util.get_now_time(),	--last received time
-- 		ip = util.inet_aton(ipaddr),
-- 	}
-- 	game_session_fds[game_session] = fd

-- end

-- skynet.dispatch("lua", function(session, source, cmd, subcmd, ...)
-- 	skynet.error(cmd)
-- end)